import pygame
from pygame import Rect, QUIT


def rayList(origin=(0, 0), stepDirection=(1, 0), length=50):
    _list = []
    i = 0
    while i < length:
        point = origin[0] + stepDirection[0] * i, origin[1] + stepDirection[1] * i
        _list.append(point)
        i += 1
    return _list


def rayRect():
    _l = []
    for i in rayList():
        _l.append(Rect(i, (0, 0)))
    return _l


pygame.init()
window = pygame.display.set_mode([800, 600])

group = pygame.sprite.Group()


def rayCast(group):
    result = []
    for rect in rayRect():
        for x in rect.collidelist(group.sprites()):
            result.append(x)
    return result


print(rayCast(group))

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()
